<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录页面</title>
</head>
<body>
<p>登录页面</p>
<form method="post">
    <p>登录名:<input name="username"/></p>
    <p>密码:<input type="password" name="password"/></p>
    <p>
        <button>登录</button>
        <a href="#" onclick="login()">钉钉登录</a>
    </p>
</form>
<script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.13.42/dingtalk.open.js"></script>
<script>
    function login() {
        let redirectUri = location.protocol + "//" + location.host + "/dingtalk/auth";
        let url = "https://login.dingtalk.com/oauth2/auth" +
            "?redirect_uri=" + encodeURIComponent(redirectUri) +
            "&response_type=code" +
            "&client_id=${dingtalk.appKey}" +
            "&scope=openid" +
            "&prompt=consent" +
            "&state=LOGIN";
        location.href = url;
    }
</script>
</body>
</html>